import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树 课程分类 树列表数据
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getTrainingtasksPage',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    keywords: queryParams.keywords,
    category: queryParams.category, //培训分类 id
    trainMode: queryParams.trainMode, //培训方式 id
    examMode: queryParams.examMode, //考试方式 id
    trainLevel: queryParams.trainLevel, //培训级别 id
    trainPlace: queryParams.trainPlace, //培训地点 id
    department: queryParams.department, //培训部门 id
    shiftId: queryParams.shiftId, //培训班组 id
    startTime: queryParams.startTime, // 开始时间
    endTime: queryParams.endTime, // 结束时间
    releaseStatus: queryParams.releaseStatus // 发布情况
  }
  return request({
    url: '/getTrainingtasksList',
    method: 'post',
    data: data
  })
}

// 新增
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId,
      title: val.title, //培训名称
      typeId: val.typeId, //培训类型 id
      typeVal: val.typeVal, //培训类型
      trainModeId: val.trainModeId, //培训方式 id
      trainMode: val.trainMode, //培训方式
      levelId: val.levelId, //培训级别 id
      levelVal: val.levelVal, //培训级别
      departmentId: val.departmentId, //培训部门 id
      department: val.department, //培训部门
      shiftId: val.shiftId, //培训班组 id
      shift: val.shift, //培训班组
      personnelIds: val.personnelIds, //参加培训人员名单id列表
      personnelNames: val.personnelNames, //参加培训人员名单（格式：部门-姓名）
      personnelNum: val.personnelNum, //参加培训人数
      placeId: val.placeId, //培训地点 id
      place: val.place, //培训地点
      speakerId: val.speakerId, //主讲人id
      speaker: val.speaker, //主讲人
      trainingplanId: val.trainingplanId, //培训计划 id
      trainingplan: val.trainingplan, //培训计划
      curriculumId: val.curriculumId, //培训课程 id
      curriculum: val.curriculum, //培训课程
      classHours: val.classHours, //培训课时
      credit: val.credit, //培训学分
      thePic: val.thePic, //培训封面图片
      introduction: val.introduction, //培训简介
      startTime: val.startTime, //培训开始时间
      endTime: val.endTime, //培训结束时间
      signinInstructions: val.signinInstructions, //签到须知
      signoutInstructions: val.signoutInstructions, //签退须知
      instructions: val.instructions, //培训须知
      examination: val.examination, //是否有考试 0-否 1-是
      examModeId: val.examModeId, //考试方式 id
      examMode: val.examMode, //考试方式
      examTaskId: val.examTaskId, //考试任务id
      examTask: val.examTask //考试任务
    }
  }
  return request({
    url: '/addTrainingtasks',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getTrainingtasksData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId,
      theid: val.theid, //id
      title: val.title, //培训名称
      typeId: val.typeId, //培训类型 id
      typeVal: val.typeVal, //培训类型
      trainModeId: val.trainModeId, //培训方式 id
      trainMode: val.trainMode, //培训方式
      levelId: val.levelId, //培训级别 id
      levelVal: val.levelVal, //培训级别
      departmentId: val.departmentId, //培训部门 id
      department: val.department, //培训部门
      shiftId: val.shiftId, //培训班组 id
      shift: val.shift, //培训班组
      personnelIds: val.personnelIds, //参加培训人员名单id列表
      personnelNames: val.personnelNames, //参加培训人员名单（格式：部门-姓名）
      personnelNum: val.personnelNum, //参加培训人数
      placeId: val.placeId, //培训地点 id
      place: val.place, //培训地点
      speakerId: val.speakerId, //主讲人id
      speaker: val.speaker, //主讲人
      trainingplanId: val.trainingplanId, //培训计划 id
      trainingplan: val.trainingplan, //培训计划
      curriculumId: val.curriculumId, //培训课程 id
      curriculum: val.curriculum, //培训课程
      classHours: val.classHours, //培训课时
      credit: val.credit, //培训学分
      thePic: val.thePic, //培训封面图片
      introduction: val.introduction, //培训简介
      startTime: val.startTime, //培训开始时间
      endTime: val.endTime, //培训结束时间
      signinInstructions: val.signinInstructions, //签到须知
      signoutInstructions: val.signoutInstructions, //签退须知
      examination: val.examination, //是否有考试 0-否 1-是
      examModeId: val.examModeId, //考试方式 id
      examMode: val.examMode, //考试方式
      examTaskId: val.examTaskId, //考试任务id
      examTask: val.examTask //考试任务
    }
  }
  return request({
    url: '/updateTrainingtasks',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delTrainingtasks',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultipleTrainingtasks(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleCurriculum',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getTrainingtasksComboBox',
    method: 'post',
    data: data
  })
}

// 课程名称 下拉
export function getCoursename(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getCurriculumList',
    method: 'post',
    data: data
  })
}

// 培训班组
export function getTeam(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getShiftList',
    method: 'post',
    data: data
  })
}

// 考试名称 下拉
export function TestName(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getExaminationtasksList',
    method: 'post',
    data: data
  })
}

// 培训计划 下拉
export function getrainPlan(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getTrainingplanList',
    method: 'post',
    data: data
  })
}

// 修改启用状态  enable 启用状态  0-未启用 1-已启用
export function getEnable(theid, enable) {
  const data = {
    projectContent: {
      theid,
      enable
    }
  }
  return request({
    url: '/changeEnableTrainingtasks',
    method: 'post',
    data: data
  })
}

// 获取课程信息单条数据
export function getcourseData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getCurriculumData',
    method: 'post',
    data: data
  })
}

// 班组名称 弹框
export function getCrew(queryParams) {
  const data = {
    theid: queryParams.theid,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
  }
  return request({
    url: '/getPersonnelListTrainingtasks',
    method: 'post',
    data: data
  })
}

// 发布 
export function getPublish(val) {
  const data = {
    projectContent: {
      theid: val.theid, //id
      reviewerId: val.reviewerId,
      reviewer: val.reviewer,
      reviewTime: val.reviewTime
    }
  }
  return request({
    url: '/toPublishTrainingtasks',
    method: 'post',
    data: data
  })
}

// 取消发布 
export function getUnPublish(theid) {
  const data = {
    theid
  }
  return request({
    url: '/unPublishTrainingtasks',
    method: 'post',
    data: data
  })
}